package smashedapples.remoting
{
	import mx.messaging.Channel;
	import mx.messaging.ChannelSet;
	import mx.messaging.channels.AMFChannel;
	import mx.rpc.remoting.mxml.Operation;
	import mx.rpc.remoting.mxml.RemoteObject;
	
	public class RemotingUtils
	{
		public static function buildRemoteOp( destination:String, endpoint:String, method:String):Operation
		{
			var ro : mx.rpc.remoting.mxml.RemoteObject  = new mx.rpc.remoting.mxml.RemoteObject();
				ro.destination = destination;
				ro.endpoint = endpoint;
			
			var channel:Channel = new  AMFChannel(null, endpoint); 
			var channelSet:ChannelSet = new ChannelSet();
    			channelSet.addChannel(channel);
		
			ro.channelSet = channelSet;

    		var operation : Operation = ro[method] as Operation;
			
			return operation;
		}
	}
}